import { AES, MD5, enc, mode, pad } from "crypto-js";
export default class AAA {
  static e(c: string, p: string) {
    const mpwd = MD5(p).toString()
    const ret = AES.encrypt(
      enc.Utf8.parse(c),
      enc.Utf8.parse(mpwd.substring(0, 16)), {
      iv: enc.Utf8.parse(mpwd.substring(16)),
      mode: mode.CBC,
      padding: pad.Pkcs7
    }).ciphertext.toString();
    return ret;
  }
  static d(c: string, p: string) {
    const mpwd = MD5(p).toString()
    const ret = AES.decrypt(
      enc.Base64.stringify(enc.Hex.parse(c)),
      enc.Utf8.parse(mpwd.substring(0, 16)), {
      iv: enc.Utf8.parse(mpwd.substring(16)),
      mode: mode.CBC,
      padding: pad.Pkcs7
    }).toString(enc.Utf8);
    return ret;
  }
};